package com.jlcindia.hibernate;

import org.hibernate.*;

public class Lab8Client {
	public static void main(String args[]) {
		Transaction tx = null;
		try {
			SessionFactory sf = HibernateUtil.getSessionFactory();
			Session session = sf.openSession();
			tx = session.beginTransaction();

			// 1.Adding students
			Student stu = new Student("sri", "Blore", "Enabled", 15000.0);
			Integer it = (Integer) session.save(stu);
			System.out.println(it.intValue());

			// 2.Adding current students
			CurrentStudent cstu = new CurrentStudent("vas", "Blore", "Enabled",
					15000.0, 2000.0, "6:30 P.M.", "BTM");
			it = (Integer) session.save(cstu);
			System.out.println(it.intValue());

			// 3.Adding old students
			OldStudent ostu = new OldStudent("aa", "Blore", "Enabled", 15000.0,
					"SDSoft", "aa@jlc.com", 9.0);
			it = (Integer) session.save(ostu);
			System.out.println(it.intValue());

			// 4.Adding regular students
			RegularStudent rstu = new RegularStudent("bb", "Blore", "Enabled",
					15000.0, 2000.0, "6:30 P.M.", "BTM", "M.Sc", "85.5", 3);
			it = (Integer) session.save(rstu);
			System.out.println(it.intValue());

			// 5.Adding weekend students
			WeekendStudent wstu = new WeekendStudent("cc", "Blore", "Enabled",
					15000.0, 2000.0, "6:30 P.M.", "HSR", "SDSoft",
					"cc@jlc.com", 9);
			it = (Integer) session.save(wstu);
			System.out.println(it.intValue());

			tx.commit();
		} catch (Exception e) {
			e.printStackTrace();
			if (tx != null)
				tx.rollback();
		}
	}
}
